﻿using System;
using System.Windows;
using System.Windows.Shapes;
using System.Text;
using System.Windows.Controls;
using System.Windows.Media;


namespace TheCollectiveNetwork.CustomControls
{
    public partial class CustomList : UserControl
    {
        public CustomList()
        {
            InitializeComponent();
        }

        // Adds an item to the list
        public void Add(String pListItem, SolidColorBrush scb)
        {

            Rectangle bullet;           
            TextBlock text_textblock;
                      
            // Create column and row definitions
          
            GridList.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
                     
            bullet = new Rectangle();
            bullet.Width = 6;
            bullet.Height = 6;
            bullet.Fill = scb;
            bullet.StrokeThickness = 1;
            bullet.Stroke = scb;
            bullet.SetValue(Grid.RowProperty, GridList.RowDefinitions.Count - 1);
            bullet.SetValue(Grid.ColumnProperty, 0);
            bullet.HorizontalAlignment = HorizontalAlignment.Center;
            bullet.VerticalAlignment = VerticalAlignment.Top;
            bullet.Margin = new Thickness(0,5,0,0);
            GridList.Children.Add(bullet);
            
            // Add the text as a child to the grid
            text_textblock = new TextBlock();
            text_textblock.Text = pListItem;
            text_textblock.SetValue(Grid.RowProperty, GridList.RowDefinitions.Count - 1);
            text_textblock.SetValue(Grid.ColumnProperty, 1);
            text_textblock.TextWrapping = TextWrapping.Wrap;
            text_textblock.HorizontalAlignment = HorizontalAlignment.Left;
            text_textblock.VerticalAlignment = VerticalAlignment.Top;
            text_textblock.Foreground = scb;
            text_textblock.Margin = new Thickness(0, 3, 0, 0);
            GridList.Children.Add(text_textblock);            

        }


        // Clears the list
        public void Clear()
        {
                       
            GridList.Children.Clear();

        }
    }
}
